package cn.eeepay.framework.dao;

import cn.eeepay.framework.db.pagination.Page;
import cn.eeepay.framework.model.AccountAddressTask;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

public interface AccountAddressTaskDao {


    @Insert("INSERT INTO account_address_task (address,account_address_id,total_amount,effective_time,status,operator,create_time ) values(" +
            "#{ac.address},#{ac.accountAddressId},#{ac.totalAmount},#{ac.effectiveTime},#{ac.status},#{ac.operator},#{ac.createTime})")
    int insert(@Param("ac") AccountAddressTask ac);

    @Delete("DELETE FROM account_address_task where id = #{id}")
    int delete(int id);

    @Delete("DELETE FROM account_address_task where address = #{address}")
    int deleteByAddress(String address);

    @Update("UPDATE account_address_task set total_amount = #{ac.totalAmount},effective_time = #{ac.effectiveTime} where id = #{ac.id}")
    int update(@Param("ac") AccountAddressTask ac);

    @Update("UPDATE account_address_task set status = #{status} where id = #{id}")
    int updateStatus(@Param("id") Integer id, @Param("status") Integer status);

    @Select("select * from account_address_task where account_address_id = #{accountAddressId} and status = 0 order by effective_time desc")
    List<AccountAddressTask> select(Integer accountAddressId);

    @Select("select * from account_address_task where account_address_id = #{accountAddressId} and status = 1 order by effective_time desc")
    List<AccountAddressTask> selectByAccountAddressId(@Param("accountAddressId") Integer accountAddressId, @Param("page") Page<AccountAddressTask> page);

    @Select("select * from account_address_task where effective_time <= #{date} and status = #{status}")
    List<AccountAddressTask> selectByStatusAndDate(@Param("date") Date date, @Param("status") Integer status);

}
